package cn.gok.thread;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
* @ClassName 线程池例子
* @Description TODO
* @Author HP
* @Date 10:43 2022/7/13
* @Version 1.0
**/
public class 线程池例子 {
    public static void main(String[] args) {
        固定线程个数的线程池();
    }

    private static void 固定线程个数的线程池() {
        ExecutorService pool =  Executors.newFixedThreadPool(2);
        pool.submit(() -> {
            System.out.println(Thread.currentThread() + "执行任务1");
        });
        pool.submit(() -> {
            System.out.println(Thread.currentThread() + "执行任务2");
        });
        pool.submit(() -> {
            System.out.println(Thread.currentThread() + "执行任务3");
        });


    }
}
